package com.sh.构造器模式;


/**
 * 普通的构造器
 * 无set方法
 */
public class Car {
    /**
     * 必需属性
     */
    private String carBody;//车身
    private String tyre;//轮胎
    private String engine;//发动机
    private String aimingCircle;//方向盘
    /**
     * 可选属性
     */
    private String decoration;//车内装饰品

    /**
     * 必需属性构造器
     * @param carBody
     * @param tyre
     * @param engine
     */
    public Car(String carBody, String tyre, String engine) {
        this.carBody = carBody;
        this.tyre = tyre;
        this.engine = engine;
    }

    /**
     * 假如我们需要再添加车内装饰品，即在原来构造器基础上再重载一个构造器
     * @param carBody
     * @param tyre
     * @param engine
     * @param aimingCircle
     * @param decoration
     */
    public Car(String carBody, String tyre, String engine, String aimingCircle, String decoration) {
        this.carBody = carBody;
        this.tyre = tyre;
        this.engine = engine;
        this.aimingCircle = aimingCircle;
        this.decoration = decoration;
    }

    @Override
    public String toString() {
        return "Car{" +
                "carBody='" + carBody + '\'' +
                ", tyre='" + tyre + '\'' +
                ", engine='" + engine + '\'' +
                ", aimingCircle='" + aimingCircle + '\'' +
                ", decoration='" + decoration + '\'' +
                '}';
    }
}


